# $Id: PKGBUILD 55525 2011-09-14 07:30:42Z andrea $
# Maintainer: Lukas Fleischer <archlinux at cryptocrack dot de>
# Contributor: Eric Belanger <eric@archlinux.org>
# Contributor: tardo <tardo@nagi-fanboi.net>
# Contributor: Thayer Williams <thayer@archlinux.org>

pkgname=libx86
pkgver=1.1
pkgrel=3
pkgdesc="Provides an lrmi interface that works on x86, am64 and alpha"
arch=('i686' 'x86_64')
url="http://www.codon.org.uk/~mjg59/libx86/"
license=('custom')
depends=('glibc')
source=("http://www.codon.org.uk/~mjg59/${pkgname}/downloads/${pkgname}-${pkgver}.tar.gz" 
        'libx86-ifmask.patch')
md5sums=('41bee1f8e22b82d82b5f7d7ba51abc2a'
         '573897186eb8670d8d97c64ea7614001')

build() {
  cd "${srcdir}"/$pkgname-$pkgver

  # lrmi.c patch courtesy of Gentoo
  patch -Np0 -i "${srcdir}"/libx86-ifmask.patch

  # compensate for x86_64
  if [ "$CARCH" = "x86_64" ]; then
    make BACKEND=x86emu
  else
    make
  fi
}

package() {
  cd "${srcdir}"/$pkgname-$pkgver

  make DESTDIR="${pkgdir}" install
  chmod 644 "${pkgdir}"/usr/lib/libx86.a

  install -D -m 644 COPYRIGHT "${pkgdir}"/usr/share/licenses/$pkgname/LICENSE
}
